{% extends "nourish/base.html" %}
{% load nourish %}
{% block title %}Register an Artist Group at {{object.name}}{% endblock %}
{% block og_title %}Register an artist group at {{ object.name }} - Feed The Artists{% endblock %}
{% block og_desc %}Use this page to register your artist group to be invited to dinners at {{ object.name }}.{% endblock %}
{% block content %}
  {% if canvas and not user.is_authenticated %}
    {% include "nourish/authorize_connect.html" %}
  {% else %}
    {% if not user.is_authenticated and not request.GET.u %}
      {% include "nourish/please_connect.html" %}
    {% else %}
      <h2>Register an Artists Group at {{object.name}}</h2>
      <p>This page is for artist groups that would like to be invited to dinner at {{object.name}}.</p>
  
      <form method="post">{% csrf_token %}
        {{ user_formset.management_form }}
        {{ group_formset.management_form }}
        {{ meal_formset.management_form }}

        {% if not user.is_authenticated %} 
          <h3>Info about you</h3>
          <p>We presume that you are the leader who will be coordinating meals for your Artist Group.  We need the information below so that we can contact you with updates about your invites, as well as other FtA-related communications.  Plus, you'll need to be able to log back into the site later to review your invitations, change your info, etc.</p>
          {{ user_formset.0.non_field_errors }}
          <table class="regform">
            {% include "nourish/form_snippet.html" with form=user_formset.0 %}
          </table>
        {% endif %}


        {% if is_fb %}
          {% if group_formset.0.group.field.choices %}
            <h3>Pick your artist group</h3>
            <p>If your project shows up below, select it. <br/><a href="?nofb">If you dont have a facebook page for your artist group click here!</a></p>
            <table class="regform">
              {{ group_formset.0.non_field_errors }}
              {% include "nourish/group_form_snippet.html" with form=group_formset.0 %}
            </table>
            <h3>What if my artist group has no Facebook presence?</h3>
            <ul>
              <li><a href="{% nurl 'fb-newgroup-options' %}">Create a new facebook page</a></li>
              <li><a href="?nofb">Continue without creating a Facebook page for your artist group</a></li>
            </ul>
          {% else %}
            {% include "nourish/fb_newgroup_options.html" with type="artist group" %}
          {% endif %}
        {% else %}
          <h3>Info about your artist group.</h3>
          <p>Please provide us a little information about your artist group so theme camps (your potential hosts) can know a bit about you.</p>
          {{ group_formset.0.non_field_errors }}
          <table class="regform">
            {% include "nourish/form_snippet.html" with form=group_formset.0 %}
          </table>
        {% endif %}

        <h3>Meals</h3>
        <p>Here's where you tell us how many crew members will be available for dinner each night of the event and if there are any special notes regarding dietary restrictions that your potential hosts should know. If you are not available for one of the dates, just leave it blank.<br/><strong>We know this information can change as we get closer to the event. If it does, please update this information here so we can notify the theme camps about the changes. (We wouldn't want 12 of you showing up when your hosts only expected 5!!!)</strong></p>
        <p class="description">Note: By registering the nights you are available, you are not guaranteed a meal; you are simply making yourselves available to be invited.</p>
            <table border=0 class="regform artist-meal-info">
              {{ meal_formset.non_field_errors }}
              <tr><th>Date</th><th>Crew</th><th>Dietary Restrictions</th><th>If yes, please explain</th></tr>
              {% for form in meal_formset %}
                {% if form.non_field_errors %}
                  <tr><td colspan=2>{{ form.non_field_errors }}</td></tr>
                {% endif %}
                <tr>
                  <td class="regdate">{{ dates.next|date:"N j" }} <em>({{ days.next|date:"D." }})</em>{{ form.date }}{% for field in form.hidden_fields %}{{ field }}{% endfor %}</td>
                  <td class="diners">{{ form.members.errors }} {{ form.members }}</td>
                  <td class="features">{{ form.features.errors }} {{ form.features }}</td>
                  <td class="notes">{{ form.notes.errors }} {{ form.notes }}</td>
                </tr>
              {% endfor %}  
          </table>

          <input type="submit" value="Register" />
      </form>
    {% endif %}
  {% endif %}
{% endblock %}
